<%inherit file="/wml/base.mako" />

<template>
	<do name="back" type="prev" label="Back">
		<prev/>
	</do>
</template>

% if c.message:
	<card id="message" title="${h.header_print(c.message['Subject'])}">
		<do type="options" label="Actions">
			<go href="#actions" />
		</do>
		<do type="prev" label="${c.message.folder}">
			<go href="${h.url_escape(h.url_for('folder_view', fname=c.message.folder ))}" />
		</do>
		<p>
			From: ${h.header_print(c.message['From'])}<br />
			<small>on ${h.header_print(c.message['Date'])}</small><br />
		</p>

		% if c.message.is_multipart() == True:
			% for i in c.message.walk():
				% if i.get_content_type() == 'text/plain':
					% if i.get_filename():
					<p>Internal part &quot;${h.escape(i.get_filename())}&quot;;<br/>Type ${h.escape(i.get_content_type())}</p>
					% endif
					<p>
					% for l in h.body_print(i).splitlines():
						${h.escape(l)}<br />
					% endfor
					</p>
				% endif
			% endfor
			<p>Structure:</p>
			<p>
			% for i in c.message.walk():
			${h.escape(i.get_content_type())} ${h.escape(i.get_filename())} ${h.escape(i['content-transfer-encoding'])} ${h.escape(i.get_charset())}<br />
			% endfor
			</p>
		% else:
			<p>
			% for l in h.body_print(c.message).splitlines():
				${h.escape(l)}<br />
			% endfor
			</p>
		% endif
	</card>
	<card id="actions" title="Actions">
		<p>Reply</p>
		<p>Reply All</p>
		<p>Forward</p>
		<p>Move</p>
		<p>Delete</p>
		<p>Copy</p>
		<p><a href="#more">More Actions</a></p>
	</card>
	<card id="more" title="More Actions">
        	<a href="${h.url_escape(h.url_for('message_headers', fname=c.message.folder, uid=c.message.uid))}">View full headers</a><br />
        	<a href="${h.url_escape(h.url_for('message_source', fname=c.message.folder, uid=c.message.uid))}">View full source</a><br />
		<%include file="/wml/common.mako" />
	</card>
% else:
	<card title="Huh">
		<p>No message.</p>
	</card>
% endif
